package cn.yuanqiao.web.controller.archive.supervision;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import cn.yuanqiao.archive.supervision.domain.HdDa;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.enums.BusinessType;

import cn.yuanqiao.archive.supervision.domain.SupervisionDa;
import cn.yuanqiao.archive.supervision.service.ISupervisionDaService;
import cn.yuanqiao.common.web.controller.BaseController;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.utils.poi.ExcelUtil;
import cn.yuanqiao.common.web.page.TableDataInfo;

/**
 * 督察指导档案列表Controller
 *
 * @author xy
 * @date 2023-08-01
 */
@RestController
@RequestMapping("/archive/supervisionDa")
public class SupervisionDaController extends BaseController
{
    @Autowired
    private ISupervisionDaService supervisionDaService;

    /**
     * 查询督察指导档案列表列表
     */
/*
    @PreAuthorize("@ss.hasPermi('archive:supervisionDa:list')")
*/
    @GetMapping("/list")
    public TableDataInfo list(SupervisionDa supervisionDa)
    {
        startPage();
        List<HdDa> list = supervisionDaService.selectHddaList(supervisionDa);
        return getDataTable(list);
    }
    @GetMapping("/hdList")
    public TableDataInfo hdList(SupervisionDa supervisionDa)
    {
        startPage();
        List<HdDa> list = supervisionDaService.selectHdDaList(supervisionDa);
        return getDataTable(list);
    }
    //通过组卷的Id获取到档案表的题名，档号，类型
    @GetMapping("/daList")
    public TableDataInfo daList(Long daId)
    {
        List<HdDa> list = supervisionDaService.selectdaList(daId);
        return getDataTable(list);
    }

    /**
     * 导出督察指导档案列表列表
     */
    @PreAuthorize("@ss.hasPermi('archive:supervisionDa:export')")
    @Log(title = "督察指导档案列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SupervisionDa supervisionDa)
    {
        List<SupervisionDa> list = supervisionDaService.selectSupervisionDaList(supervisionDa);
        ExcelUtil<SupervisionDa> util = new ExcelUtil<SupervisionDa>(SupervisionDa.class);
        util.exportExcel(response, list, "督察指导档案列表数据");
    }

    /**
     * 获取督察指导档案列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive:supervisionDa:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(supervisionDaService.selectSupervisionDaByID(id));
    }

    /**
     * 新增督察指导档案列表
     */
/*
    @PreAuthorize("@ss.hasPermi('archive:supervisionDa:add')")
*/
    @Log(title = "督察指导档案列表", businessType = BusinessType.INSERT)
    @PostMapping
    @PreAuthorize("@ss.hasPermi('archive:supervisionDa:fileOrganization')")
    public AjaxResult add(@RequestBody List<SupervisionDa> supervisionDaList)
    {
        return toAjax(supervisionDaService.insertSupervisionDa(supervisionDaList));
    }
    /**
     * 新增督察指导档案列表
     */
/*
    @PreAuthorize("@ss.hasPermi('archive:supervisionDa:add')")
*/
    @Log(title = "督察指导档案列表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @PreAuthorize("@ss.hasPermi('archive:supervisionDa:fileManagement')")
    public AjaxResult addDa(@RequestBody List<SupervisionDa> supervisionDaList)
    {
        return toAjax(supervisionDaService.insertSupervisionDa(supervisionDaList));
    }
    /**
     * 修改督察指导档案列表
     */
    @PreAuthorize("@ss.hasPermi('archive:supervisionDa:edit')")
    @Log(title = "督察指导档案列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SupervisionDa supervisionDa)
    {
        return toAjax(supervisionDaService.updateSupervisionDa(supervisionDa));
    }

    /**
     * 删除督察指导档案列表
     */
/*
    @PreAuthorize("@ss.hasPermi('archive:supervisionDa:remove')")
*/
    @Log(title = "督察指导档案列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(supervisionDaService.deleteSupervisionDaByIDs(ids));
    }
}
